﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApp0
{
    public partial class buy : Form
    {
        string m;
        string c;
        string o;
        public buy()
        {
            InitializeComponent();
        }
        public buy(string mid,string cid)
        {
            this.m = mid;
            this.c = cid;
 
            InitializeComponent();
        }

        private void button5_Click(object sender, EventArgs e)
        {//shu liang                      time             place
            if (textBox2.Text == "" || textBox4.Text == "" || textBox3.Text == "" )
            {
                MessageBox.Show("输入有空, 请检查", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);

            }
            else
            {
                try
                {

                    Dao dao = new Dao();
                    string sql = $"insert into OrderM values('{DateTime.Now.ToString("yyyyMMddHHmmss")+"C"+c}','{c}','{m}',{textBox2.Text},'{textBox3.Text}','{textBox4.Text}','待确认',null)";
                    
                    int n = dao.Execute(sql);
                    
                    if (n > 0)
                    {
                       
                        MessageBox.Show("添加成功");

                    }
                }
                catch
                {
                    MessageBox.Show("编号重复，添加失败");
                }

            }
        }

        private void buy_Load(object sender, EventArgs e)
        {

        }
    }
}
